MkConfigSetting
:fa-brands-github: Show source on GitHub
Node for describing a config setting.¶
Example: YAML format¶
Jinja
Python
**path**-
Default:
'path.to.module'Some markdown to describe the setting
Example: JSON format¶
Jinja
Python
**path**-
Default:
'path.to.module'Some markdown to describe the setting
Example: TOML format¶
Jinja
Python
**path**-
Default:
'path.to.module'Some markdown to describe the setting
Bases: MkTemplate
__init__
¶
__init__(
title: str,
description: str,
*,
setting: dict[str, Any] | str | None = None,
default: str | int | None = None,
version_added: str | None = None,
optional: bool | None = None,
mode: MarkupTypeStr = "yaml",
**kwargs: Any
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Setting title |
required |
description
|
str
|
Setting description |
required |
setting
|
dict[str, Any] | str | None
|
(Nested) json-like object representing the setting |
None
|
default
|
str | int | None
|
Default setting value |
None
|
version_added
|
str | None
|
Version added |
None
|
optional
|
bool | None
|
Whether setting is optional. (None hides the label) |
None
|
mode
|
MarkupTypeStr
|
Markup language of settings file |
'yaml'
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
| Name | Children | Inherits |
|---|---|---|
| MkTemplate mknodes.templatenodes.mktemplate Node representing a jinja template. |
graph TD
1561279813["mkconfigsetting.MkConfigSetting"]
1289759389["mktemplate.MkTemplate"]
3160803176["rendercache.TemplateRenderMixin"]
2751680898["builtins.object"]
835538629["mkcontainer.MkContainer"]
1956333208["mkcontainer.MkContainerBase"]
1359323199["mknode.MkNode"]
1289759389 --> 1561279813
3160803176 --> 1289759389
2751680898 --> 3160803176
835538629 --> 1289759389
1956333208 --> 835538629
1359323199 --> 1956333208
2751680898 --> 1359323199
/home/runner/work/mknodes/mknodes/src/mknodes/templatenodes/mkconfigsetting/metadata.toml
[metadata]
name = "MkConfigSetting"
icon = "mdi:library"
virtual_children = true
[requirements.extension.def_list]
[examples.yaml]
title = "YAML format"
jinja = """
{{ "path" | MkConfigSetting(mode="yaml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.json]
title = "JSON format"
jinja = """
{{ "path" | MkConfigSetting(mode="json",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[examples.toml]
title = "TOML format"
jinja = """
{{ "path" | MkConfigSetting(mode="toml",
setting={"plugins": {"mknodes": {"path": "path.to.module"}}},
description="Some **markdown** to describe the setting",
default="path.to.module")}}
"""
[output.markdown]
template = """
{{ node.title | md_style(bold=True, code=True) }}
: {% filter indent %}Default: `{{ node.default | repr }}`
{% if node.version_added %}
Version added: `{{ node.version_added }}`
{% endif %}
{% if node.optional is not none %}
Required: `{{ "yes" if node.required else "no" }}`
{% endif %}
{{ node.description }}
{% if node.setting is instance(dict) %}
{{ node.setting | serialize(node.mode) | MkCode(language=node.mode) }}
{% else %}
{{ node.setting | MkCode(language=node.mode) }}
{% endif %}
{% endfilter %}
"""